/*************************************************************************************
 *
 *  Revolution Engine
 *  Copyright (C) 2009 Felipe Apablaza
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 ************************************************************************************/


//---------------------------------------------------------
//
//  File:	IObject.hpp
//  Desc:	Contain the IObject's interface, root for 
//			shared and abstracting classes.
//
//---------------------------------------------------------

#ifndef __REVENG_IOBJECT_HPP__
#define __REVENG_IOBJECT_HPP__

#include <typeinfo>
#include <RevEng/Config.h>
#include <RevEng/DataTypes.hpp>
#include <RevEng/IObjCreator.hpp>

namespace RevEng
{
	class __REVENG_EXPORT__ IObject
	{
	private:
		Int32 m_nRefCount;

	public:
		IObject();
		virtual ~IObject() = 0;

		//Increase by one unit the reference counter
		void AddRef();

		//Decrease by one unit the reference counter.
		void Release();
		
		//return the corresponding class id.
		virtual Enum GetClassId() const;

	public:
		//Create a new object of the specified type
		static IObject* New(Enum ClassId);

		//Register a new IObjCreator allocator.
		static void RegisterObjCreator(IObjCreator* Creator);

		static void Recycle(Enum ClassId);
	};


	inline IObject::IObject() : m_nRefCount(0)
	{
	}

	inline IObject::~IObject()
	{
	}

	inline void IObject::AddRef()
	{
		++m_nRefCount;
	}

	inline Enum IObject::GetClassId() const
	{
		return 0;
	}
}

#endif	//__REVENG_IMPL_IOBJECT_HPP__
